package com.gf.user.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * 
 * @author zhuguifeng guifeng.net@gmail.com
 * @version 创建时间：2012-10-11 下午12:39:52
 */
@Service("diseaseDao")
public class DiseaseDaoImpl implements com.gf.user.dao.DiseaseDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * select en_name from disease
	 */
	@Value("${diseaseDao.queryChNameSql}")
	private String queryChNameSql;

	/**
	 * select ch_name from disease
	 */
	@Value("${diseaseDao.queryEnNameSql}")
	private String queryEnNameSql;

	/**
	 * select en_name,ch_name from disease
	 */
	@Value("${diseaseDao.queryEnChMapSql}")
	private String queryEnChMapSql;

	@Override
	public List<String> queryChName() {
		return jdbcTemplate.queryForList(queryChNameSql, String.class);
	}

	@Override
	public List<String> queryEnName() {
		return jdbcTemplate.queryForList(queryEnNameSql, String.class);
	}

	@Override
	public Map<String, String> queryEnChMap() {
		Map<String, Object> map = jdbcTemplate.queryForMap(queryEnChMapSql);
		Map<String, String> result = new HashMap<String, String>();
		Set<String> keys = map.keySet();
		for (String key : keys) {
			result.put(key, String.valueOf(map.get(key)));
		}
		return result;
	}

}
